package com.erp.stock.controller;

import com.erp.common.ResponseMessage;
import com.erp.common.controller.BaseControllerPowerful;
import com.erp.common.service.BaseService;
import com.erp.produce.vo.RawMaterialInventoryVO;
import com.erp.stock.entity.RawMaterialInventory;
import com.erp.stock.service.RawMaterialInventoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("原材料库存接口")
@RestController
@RequestMapping("/rmInventory")
public class RawMaterialInventoryController extends BaseControllerPowerful<RawMaterialInventory> {
    @Autowired
    RawMaterialInventoryService service;


    @Override
    protected BaseService getService() {
        return this.service;
    }

    @PostMapping("/list/save")
    public ResponseMessage saveList(@RequestBody RawMaterialInventoryVO[] rawMaterialInventoryVOS){
        for (int i = 0; i < rawMaterialInventoryVOS.length; i++) {
            System.out.println(rawMaterialInventoryVOS[i]);
        }
        Boolean success = service.saveList(rawMaterialInventoryVOS);
        if (success) {
           return ResponseMessage.ok();
        }
        return ResponseMessage.fail("失败，请重试");
    }
}
